package org.summerframework.component.security.enumeration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 石超
 * @version v1.0.0
 */
public enum LogoutTypeEnum {

    NORMAL(1, "您的账号在另一处登录。"),
    FORBIDDEN(2, "您的账号已被禁用\n请联系客服"),
    DELETE(3, "您的账号已被删除\n请联系客服"),
    WAIT_ACTIVATE(4, "您的账号未激活\n请激活后重试");

    private Integer status;
    private String desc;

    private LogoutTypeEnum(int status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public static LogoutTypeEnum toEnum(Integer status) {
        if (status == null) {
            return null;
        }

        for (LogoutTypeEnum value : values()) {
            if (value.getStatus().equals(status)) {
                return value;
            }
        }
        return null;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static List<LogoutTypeEnum> getList() {
        List<LogoutTypeEnum> statusEnums = new ArrayList<>();

        for (LogoutTypeEnum sourceEnum : values()) {
            if (sourceEnum.status > -1) {
                statusEnums.add(sourceEnum);
            }
        }

        return statusEnums;
    }
}
